package com.zy.explore.license.infrastructure.license;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.zy.explore.license.infrastructure.config.LicenseConfig;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

/**
 * License生成类需要的参数
 *
 * @author zifangsky
 * @date 2018/4/19
 * @since 1.0.0
 */
@ApiModel("生成证书参数")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class LicenseCreatorParam implements Serializable {

    private static final long serialVersionUID = -7793154252684580872L;

    /**
     * 证书subject
     */
    @JsonIgnore
    @ApiModelProperty(value = "证书subject", example = "tl-customer")
    private String subject;

    /**
     * 密钥别称
     */
    @JsonIgnore
    @ApiModelProperty(value = "密钥别称", required = true, example = "privateKey")
    private String privateAlias = LicenseConfig.privateAlias;

    /**
     * 密钥密码(需要妥善保管，不能让使用者知道)
     */
    @JsonIgnore
    @ApiModelProperty(value = "密钥密码(需要妥善保管，不能让使用者知道)", required = true, example = "private_password1234")
    private String keyPass = LicenseConfig.privateStorePass;

    /**
     * 访问秘钥库的密码
     */
    @JsonIgnore
    @ApiModelProperty(value = "访问秘钥库的密码", required = true, example = "public_password1234")
    private String publicStorePass = LicenseConfig.publicStorePass;

    /**
     * 证书生成路径
     */
    @ApiModelProperty(value = "证书生成路径", required = true, example = "D:/license")
    private String licensePath;

    /**
     * 密钥库存储路径
     */
    @JsonIgnore
    @ApiModelProperty(value = "密钥库存储路径", required = true, example = "D:/license")
    private String privateKeysStorePath;

    /**
     * 证书生效时间
     */
    @ApiModelProperty(value = "证书发行时间，默认不传则为当前时间", example = "2022-04-01 00:00:00")
    @JsonIgnore
    private Date issuedTime = new Date();

    /**
     * 证书失效时间
     */
    @ApiModelProperty(value = "证书失效时间", example = "2023-04-01 00:00:00")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date expiryTime;

    /**
     * 用户类型
     */
    @JsonIgnore
    @ApiModelProperty(value = "用户类型，默认user", example = "user")
    private String customerType = "user";

    /**
     * 用户数量
     */
    @JsonIgnore
    @ApiModelProperty(value = "用户数量，默认1", example = "1")
    private Integer consumerAmount = 1;

    /**
     * 描述信息
     */
    @ApiModelProperty(value = "描述信息", example = "系统证书")
    private String description;

    /**
     * 额外的服务器硬件校验信息
     */
    @ApiModelProperty(value = "服务器硬件信息", required = true)
    private LicenseCheckModel licenseCheckModel;
}
